<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
	<ui:composition template="./main.xhtml">
		<ui:define name="content">
		<f:event listener="#{dayController.initialize}" type="preRenderView"></f:event>
		<br/>
		<h:form>
		<p:tabView activeIndex="#{staffConversation.activeIndex}">
			<p:tab title="利用者">
				<p:panelGrid columns="1">
					<f:facet name="header">
						<p:commandButton value="登録" action="#{staffController.createStaff}" styleClass="button_small"/>
		   			</f:facet>
		   			<p:dataTable value="#{staffController.staffList}" var="record">
						<p:column headerText="ログイン名">
							<h:outputText value="#{record.userName}"/>
						</p:column>
						<p:column headerText="日華用氏名">
							<h:outputText value="#{record.formalName}"/>
						</p:column>
						<p:column headerText="状態">
							<h:outputText value="#{record.used ? '使用' : '未使用'}"/>
						</p:column>
						<p:column headerText="並び順">
							<h:outputText value="#{record.index}"/>
						</p:column>
						<p:column>
							<p:commandButton action="#{staffController.editStaff}" value="編集" styleClass="button_small">
								<f:setPropertyActionListener target="#{staffConversation.selectStaff}" value="#{record}" />
							</p:commandButton>
							<p:commandButton action="#{staffController.deleteStaff}" value="削除" styleClass="button_small">
								<f:setPropertyActionListener target="#{staffConversation.selectStaff}" value="#{record}"/>
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:panelGrid>
			</p:tab>
			<p:tab title="グループ">
				<p:panelGrid columns="1">
					<f:facet name="header">
						<p:commandButton value="登録" action="#{staffGroupController.createStaffGroup}" styleClass="button_small"/>
		   			</f:facet>
		   			<p:dataTable value="#{staffGroupController.staffGroupList}" var="record" emptyMessage="グループがないです。">
						<p:column headerText="グループ名">
							<h:outputText value="#{record.name}"/>
						</p:column>
						<p:column headerText="並び順">
							<h:outputText value="#{record.index}"/>
						</p:column>
						<p:column>
							<p:dataGrid columns="2" value="#{record.staffs}" var="staff">
								<h:outputText value="#{staff.formalName}"></h:outputText>
							</p:dataGrid>
						</p:column>
						<p:column>
							<p:commandButton action="#{staffGroupController.editStaffGroup}" value="編集" styleClass="button_small">
								<f:setPropertyActionListener target="#{staffGroupConversation.selectStaffGroup}" value="#{record}" />
							</p:commandButton>
							<p:commandButton action="#{staffGroupController.deleteStaffGroup}" value="削除" styleClass="button_small">
								<f:setPropertyActionListener target="#{staffGroupConversation.selectStaffGroup}" value="#{record}" />
							</p:commandButton>
							<p:commandButton action="#{staffGroupController.setPermission}" value="権限" styleClass="button_small">
								<f:setPropertyActionListener target="#{staffGroupConversation.selectStaffGroup}" value="#{record}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:panelGrid>
			</p:tab>
		</p:tabView>
		</h:form>
		</ui:define>
	</ui:composition>
</html>